package com.songlanyun.modules.offlineorderincome.entity;

import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;

import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.enums.OfflineOrderConstant;
import com.songlanyun.modules.offlineorder.entity.OfflineOrder;
import com.songlanyun.modules.offlineorder.service.OfflineOrderService;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 线下订单分润表
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2023-02-15 13:54:23
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("yxt_offline_order_income")
public class OfflineOrderIncome extends RootEntity<Long,OfflineOrderIncome> implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 *
	 */
	@TableId
	private Long id;
	/**
	 * 关联的线下订单
	 */
	private Long offlineOrderId;
	/**
	 * 所得用户id
	 */
	private Long incomeUserId;
	/**
	 * 所得用户名称
	 */
	private String incomeUserName;
	/**
	 * 所得用户手机
	 */
	private String incomeUserMobile;
	/**
	 * 所得积分
	 */
	private BigDecimal incomePoint;
	/**
	 * 所得类型
	 */
	private OfflineOrderConstant.IncomeType incomeType;
	/**
	 * 创建时间
	 */
	private Date createTime;
	/**
	 * 是否已结算
	 */
	private Boolean settlement;

	@TableField(exist = false)
	private OfflineOrder offlineOrder;

	public OfflineOrder loadOfflineOrder()
	{
		OfflineOrderService offlineOrderService = SpringUtil.getBean("offlineOrderService", OfflineOrderService.class);
		this.offlineOrder = offlineOrderService.getById(this.offlineOrderId);
		return this.offlineOrder;
	}


	@Override
	public Long getIdentity() {
		return getId();
	}
}
